<html>
<head><meta charset="utf-8"><title>Query `is_structural_eq_shallow` for generic type · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Query.20.60is_structural_eq_shallow.60.20for.20generic.20type.html">Query `is_structural_eq_shallow` for generic type</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242706738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Query%20%60is_structural_eq_shallow%60%20for%20generic%20type/near/242706738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Query.20.60is_structural_eq_shallow.60.20for.20generic.20type.html#242706738">(Jun 15 2021 at 09:15)</a>:</h4>
<p>Hi folks: let's say I have structs like</p>
<div class="codehilite"><pre><span></span><code>#[derive(PartialEq, Eq)]
struct Wrapper&lt;T&gt; {
  value: T,
}
</code></pre></div>
<p>The expansion includes:</p>
<div class="codehilite"><pre><span></span><code>impl &lt;T&gt; ::core::marker::StructuralPartialEq for Wrapper&lt;T&gt; { }
impl &lt;T&gt; ::core::marker::StructuralEq for Wrapper&lt;T&gt; { }
</code></pre></div>
<p>From <code>TyCtxt</code>, can I determine whether these impls are present for any T? (For the unapplied <code>Wrapper&lt;T&gt;</code>, querying <code>is_structural_eq_shallow</code> or querying whether <code>Wrapper&lt;T&gt;</code> implements the trait <code>StructuralPartialEq</code> returns false.)</p>



<a name="242771411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Query%20%60is_structural_eq_shallow%60%20for%20generic%20type/near/242771411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Query.20.60is_structural_eq_shallow.60.20for.20generic.20type.html#242771411">(Jun 15 2021 at 17:42)</a>:</h4>
<p>More in general the question here I guess is: can I query whether a type that still has (unapplied) type parameters, e.g. querying whether <code>Wrapper&lt;T&gt;</code> implements <code>StructuralPartialEq</code> or any other trait?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>